package org.example.demo8;

import lombok.extern.slf4j.Slf4j;

/**
 * 线程组&线程 的优先级
 *
 * @author : Gong.Yang
 */
@Slf4j
public class Main {
    public static void main(String[] args) {
        ThreadGroup threadGroup = new ThreadGroup("group-0");
        threadGroup.setMaxPriority(7);

        Thread thread0 = new Thread(threadGroup, () -> log.info("【Thread0】 优先级->{}", Thread.currentThread().getPriority()));

        Thread thread1 = new Thread(threadGroup, () -> log.info("【Thread1】 优先级->{}", Thread.currentThread().getPriority()));
        thread1.setPriority(9); //只有这个受到了影响，结果是7

        Thread thread2 = new Thread(threadGroup, () -> log.info("【Thread2】 优先级->{}", Thread.currentThread().getPriority()));
        thread2.setPriority(3);

        log.info("【优先级】thread0->{},thread1->{},thread2->{}", thread0.getPriority(),thread1.getPriority(),thread2.getPriority());

    }
}
